import { request } from 'umi';
import { RequestOptionsInit } from 'umi-request';
/**
 * post请求
 * @param url 
 * @param data 
 * @param config 
 * @returns 
 */
export async function post<T>(url: string, data?: any, config?: RequestOptionsInit) {
  return request<T>(url, {
    ...config,
    data,
    method: 'POST',
  });
}

/**
 * get请求
 * @param url 
 * @param data 
 * @param config 
 * @returns 
 */
export async function get<T>(url: string, data?: any, config?: RequestOptionsInit) {
  return request<T>(url, {
    ...config,
    params: data,
    method: 'GET'
  });
}

/**
 * form请求
 * @param url 
 * @param data 
 * @param config 
 * @returns 
 */
export async function postForm<T>(url: string, data?: any, config?: RequestOptionsInit) {
  return request<T>(url, {
    ...config,
    requestType: 'form',
    data,
    method: 'POST',
  });
}